{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "ncnn implementation of RIFE, Real-Time Intermediate Flow Estimation for Video Frame Interpolation.\n",
    "Currently in testing, memory and GPU are very low utilization, future improvements\n",
    "当前仅供测试，由于开发时并发数过高导致报错，相比桌面版APP降低了一半多并发数，colab实际测试中GPU并没有完全消耗。由于我这边colab已到达上限，开发暂时搁置到下个周期。\n",
    "src:[Baiyuetribe/paper2gui](https://github.com/Baiyuetribe/paper2gui/blob/main/Video%20Frame%20Interpolation/rife-gui.md)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!apt install libvulkan-dev -y # install vulkan\n",
    "# download rife4 \n",
    "!wget https://github.com/Baiyuetribe/paper2gui/releases/download/Published/colab_rife.zip\n",
    "!unzip colab_rife.zip\n",
    "!chmod +x rife\n",
    "!./rife"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# upload you video\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example\n",
    "Input : in.mp4\n",
    "Ouput : out.mp4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# step[1/3]: Audio Extraction\n",
    "!ffmpeg -i in.mp4 -vn -acodec copy -y tmp_audio.m4a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# step[2/3]: Video frame interpolation\n",
    "!./rife in.mp4 tmp_out.mp4 2\n",
    "# format rife [in.mp4] [out.mp4] [2/3/4] frame scale"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# step[3/3]: Audio + Video Merge\n",
    "!ffmpeg -i tmp_out.mp4 -i tmp_audio.mp4 -c copy -shortest out.mp4"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
